import copy
nn=20
mm=[1,4,6,7,7,9,11,13,15,16]
        
def binpacking(n,m):
    ret=[]
    solution=[]
    S=n
    A=copy.deepcopy(m)
    #BF
    #i chose put the bigger object first, 
    #because if a object weigh is closed to S/2, it could put with small object in a package,
    A=sorted(A,reverse=True) 
    while True:
        if not A:   #A is empty return
            break
        for i in A: #find the most object pair to the package
            if(S-i>=0):
                S=S-i
                ret.append(i)                         
        solution.append(ret)
        for j in ret:
            A.remove(j)  
        ret=[]
        S=n
    
    return solution
            
possolution = binpacking(nn,mm)
print possolution